double x2, double y2, double z2,
double* xa, double* ya, double* za)
{
- *xa = y1*z2-y2*z1;
- *ya = z1*x2-z2*x1;
- *za = x1*y2-y1*x2;
+ *xa = y1 * z2 - y2 * z1;
+ *ya = z1 * x2 - z2 * x1;
+ *za = x1 * y2 - y1 * x2;
}
static double dotproduct(double x1, double y1, double z1,
double x2, double y2, double z2)
{
- return (x1*x2+y1*y2+z1*z2);
+ return (x1 * x2 + y1 * y2 + z1 * z2);
}
/*
double radtomiles(double rads)
{
- const double radmiles = EARTH_RAD*100.0/2.54/12.0/5280.0;
- return (rads*radmiles);
+ const double radmiles = EARTH_RAD * 100.0 / 2.54 / 12.0 / 5280.0;
+ return (rads * radmiles);
}
double radtometers(double rads)
res = asin(res);
- if (
-#if defined isnan
- /* This is a C99-ism. */
- isnan(res) ||
-#endif
- errno == EDOM) { /* this should never happen: */
- errno = 0; /* Math argument out of domain of
- function, */
- return 0; /* or value returned is not a number */
+ if (isnan(res) || (errno == EDOM)) { /* this should never happen: */
+ errno = 0; /* Math argument out of domain of function, */
+ return 0; /* or value returned is not a number */
}
return 2.0 * res;
double* prjlat, double* prjlon,
double* frac)
{
-
static double _lat1 = -9999;
static double _lat2 = -9999;
static double _lon1 = -9999;
static double _lon2 = -9999;
- static double x1,y1,z1;
- static double x2,y2,z2;
- static double xa,ya,za,la;
+ static double x1, y1, z1;
+ static double x2, y2, z2;
+ static double xa, ya, za, la;
- double x3,y3,z3;
- double xp,yp,zp,lp;
+ double x3, y3, z3;
+ double xp, yp, zp, lp;
- double xa1,ya1,za1;
- double xa2,ya2,za2;
+ double xa1, ya1, za1;
+ double xa2, ya2, za2;
double d1, d2;
double c1, c2;
/* polar to ECEF rectangular */
if (newpoints) {
- x1 = cos(lon1)*cos(lat1);
+ x1 = cos(lon1) * cos(lat1);
y1 = sin(lat1);
- z1 = sin(lon1)*cos(lat1);
- x2 = cos(lon2)*cos(lat2);
+ z1 = sin(lon1) * cos(lat1);
+ x2 = cos(lon2) * cos(lat2);
y2 = sin(lat2);
- z2 = sin(lon2)*cos(lat2);
+ z2 = sin(lon2) * cos(lat2);
}
- x3 = cos(lon3)*cos(lat3);
+ x3 = cos(lon3) * cos(lat3);
y3 = sin(lat3);
- z3 = sin(lon3)*cos(lat3);
+ z3 = sin(lon3) * cos(lat3);
if (newpoints) {
/* 'a' is the axis; the line that passes through the center of the earth
* and is perpendicular to the great circle through point 1 and point 2
* It is computed by taking the cross product of the '1' and '2' vectors.*/
crossproduct(x1, y1, z1, x2, y2, z2, &xa, &ya, &za);
- la = sqrt(xa*xa+ya*ya+za*za);
+ la = sqrt(xa * xa + ya * ya + za * za);
if (la) {
xa /= la;
}
}
if (la) {
-
/* dot is the component of the length of '3' that is along the axis.
* What's left is a non-normalized vector that lies in the plane of
* 1 and 2. */
- dot = dotproduct(x3,y3,z3,xa,ya,za);
+ dot = dotproduct(x3, y3, z3, xa, ya, za);
- xp = x3-dot*xa;
- yp = y3-dot*ya;
- zp = z3-dot*za;
+ xp = x3 - dot * xa;
+ yp = y3 - dot * ya;
+ zp = z3 - dot * za;
- lp = sqrt(xp*xp+yp*yp+zp*zp);
+ lp = sqrt(xp * xp + yp * yp + zp * zp);
if (lp) {
-
/* After this, 'p' is normalized */
xp /= lp;
yp /= lp;
zp /= lp;
- crossproduct(x1,y1,z1,xp,yp,zp,&xa1,&ya1,&za1);
+ crossproduct(x1, y1, z1, xp, yp, zp, &xa1, &ya1, &za1);
d1 = dotproduct(xa1, ya1, za1, xa, ya, za);
- crossproduct(xp,yp,zp,x2,y2,z2,&xa2,&ya2,&za2);
+ crossproduct(xp, yp, zp, x2, y2, z2, &xa2, &ya2, &za2);
d2 = dotproduct(xa2, ya2, za2, xa, ya, za);
if (d1 >= 0 && d2 >= 0) {
} else {
*prjlon = DEG(atan2(zp, xp));
}
- *frac = d1/(d1 + d2);
+ *frac = d1 / (d1 + d2);
- return atan(fabs(dot)/lp);
+ return atan(fabs(dot) / lp);
}
/* otherwise, get the distance from the closest endpoint */
- c1 = dotproduct(x1,y1,z1,xp,yp,zp);
- c2 = dotproduct(x2,y2,z2,xp,yp,zp);
+ c1 = dotproduct(x1, y1, z1, xp, yp, zp);
+ c2 = dotproduct(x2, y2, z2, xp, yp, zp);
d1 = fabs(d1);
d2 = fabs(d2);
}
if (fabs(d1) < fabs(d2)) {
- return gcdist(lat1,lon1,lat3,lon3);
+ return gcdist(lat1, lon1, lat3, lon3);
} else {
*prjlat = DEG(lat2);
*prjlon = DEG(lon2);
*frac = 1.0;
- return gcdist(lat2,lon2,lat3,lon3);
+ return gcdist(lat2, lon2, lat3, lon3);
}
} else {
/* lp is 0 when 3 is 90 degrees from the great circle */
- return M_PI/2;
+ return M_PI / 2;
}
} else {
/* la is 0 when 1 and 2 are either the same point or 180 degrees apart */
- dot = dotproduct(x1,y1,z1,x2,y2,z2);
+ dot = dotproduct(x1, y1, z1, x2, y2, z2);
if (dot >= 0) {
- return gcdist(lat1,lon1,lat3,lon3);
+ return gcdist(lat1, lon1, lat3, lon3);
} else {
return 0;
}
}
}
-
double linedist(double lat1, double lon1,
double lat2, double lon2,
double lat3, double lon3)
double frac,
double* reslat, double* reslon)
{
-
- double x1,y1,z1;
- double x2,y2,z2;
- double xa,ya,za,la;
+ double x1, y1, z1;
+ double x2, y2, z2;
+ double xa, ya, za, la;
double xr, yr, zr;
double xx, yx, zx;
lon2 = RAD(lon2);
/* polar to ECEF rectangular */
- x1 = cos(lon1)*cos(lat1);
+ x1 = cos(lon1) * cos(lat1);
y1 = sin(lat1);
- z1 = sin(lon1)*cos(lat1);
- x2 = cos(lon2)*cos(lat2);
+ z1 = sin(lon1) * cos(lat1);
+ x2 = cos(lon2) * cos(lat2);
y2 = sin(lat2);
- z2 = sin(lon2)*cos(lat2);
+ z2 = sin(lon2) * cos(lat2);
/* 'a' is the axis; the line that passes through the center of the earth
* and is perpendicular to the great circle through point 1 and point 2
* It is computed by taking the cross product of the '1' and '2' vectors.*/
crossproduct(x1, y1, z1, x2, y2, z2, &xa, &ya, &za);
- la = sqrt(xa*xa+ya*ya+za*za);
+ la = sqrt(xa * xa + ya * ya + za * za);
if (la) {
xa /= la;
if (la) {
crossproduct(x1, y1, z1, xa, ya, za, &xx, &yx, &zx);
-
theta = atan2(dotproduct(xx,yx,zx,x2,y2,z2),
dotproduct(x1,y1,z1,x2,y2,z2));
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
*/
+#ifndef HEIGHT_H_INCLUDED_
+#define HEIGHT_H_INCLUDED_
+
/* Created by "tools/createGeoidGrid 1.0 int8_t" using GeographicLib utility GeoidEval with egm96-5. */
+
+#include <stdint.h>
+
#define GEOID_GRID_DEG 1.0
#define GEOID_SCALE 1.0
#define GEOID_ROW 181
/* 89.0 */ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
/* 90.0 */ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
};
+#endif // HEIGHT_H_INCLUDED_